package com.starblink.android.common.view.post

import android.view.ViewGroup
import com.starblink.android.basic.adapter.BaseVH
import com.starblink.android.basic.ext.commContext
import com.starblink.android.basic.extension.navigationTo
import com.starblink.android.basic.sensorsdata.spm.cfg.SpmPageDef
import com.starblink.basic.route.RoutePage
import com.starblink.rocketreserver.fragment.PostF
import view.post.PostCardView

class SimplePostCardCell(
    parent: ViewGroup,
    val list: ArrayList<PostF>, val isLastOne: () -> Unit
) : BaseVH<PostF>(PostCardView(parent.context)) {

    private val cardView = itemView as PostCardView

    override fun onBind(post: PostF, position: Int) {
        cardView.bindPost(post, position, false, spmPageValue = SpmPageDef.ContentDeletedRoute) {
            commContext().navigationTo(if (post.contentType == "1") RoutePage.Post.PAGE_PIC else RoutePage.PostVideo.PAGE_VIDEO) {
                withInt(RoutePage.Post.ARG_SCENE, RoutePage.Post.SCENE.OTHER.value)
                withString(RoutePage.Post.POST_ID, post.id)
                withObject(RoutePage.Post.POST, post)
            }
        }
        if (list.size > 4 && position == list.size - 6) {
            isLastOne()
        }
    }
}